#ifndef _LPC2378PINSEL_H_
#define _LPC2378PINSEL_H_


//*******************************************************
// PINSEL0
#define P0_0_RD1    1
#define P0_0_TXD3   2
#define P0_0_SDA1   3

#define P0_1_TD1    (1<<2)
#define P0_1_RXD3   (2<<2)
#define P0_1_SCL1   (3<<2)

#define P0_2_TDX0   (1<<4)
//#define P0_2_     // reserved
//#define P0_2_     // reserved

#define P0_3_RXD0   (1<<6)
//#define P0_3_     // reserved
//#define P0_3_     // reserved

#define P0_4_I2SRX_CLK  (1<<8)
#define P0_4_RD2        (2<<8)
#define P0_4_CAP2_0     (3<<8)

#define P0_5_I2SRX_WS   (1<<10)
#define P0_5_TD2        (2<<10)
#define P0_5_CAP2_1     (3<<10)

#define P0_6_I2SRX_SDA  (1<<12)
#define P0_6_SSEL1      (2<<12)
#define P0_6_MAT2_0     (3<<12)

#define P0_7_I2STX_CLK  (1<<14)
#define P0_7_SCK1       (2<<14)
#define P0_7_MAT2_1     (3<<14)

#define P0_8_I2STX_WS   (1<<16)
#define P0_8_MISO1      (2<<16)
#define P0_8_MAT2_2     (3<<16)

#define P0_9_I2STX_SDA  (1<<18)
#define P0_9_MOSI1      (2<<18)
#define P0_9_MAT2_3     (3<<18)

#define P0_10_TXD2      (1<<20)
#define P0_10_SDA2      (2<<20)
#define P0_10_MAT3_1    (3<<20)

#define P0_11_RXD2      (1<<22)
#define P0_11_SCL2      (2<<22)
#define P0_11_MAT3_1    (3<<22)

#define P0_12_USBPPWR2  (1<<24)
#define P0_12_MISO1     (2<<24)
#define P0_12_AD0_6     (3<<24)

#define P0_13_USB_UP_LED2   (1<<26)
#define P0_13_MOSI1         (2<<26)
#define P0_13_AD0_7         (3<<26)

#define P0_14_USB_HSTEN2    (1<<28)
#define P0_14_USB_CONNECT2  (2<<28)
#define P0_14_SSEL1         (3<<28)

#define P0_15_TXD1          (1<<30)
#define P0_15_SCK0          (2<<30)
#define P0_15_SCK           (3<<30)

//*******************************************************
// PINSEL1
#define P0_16_RXD1          (1<<0)
#define P0_16_SSEL0         (2<<0)
#define P0_16_SSEL          (3<<0)

#define P0_17_CTS1          (1<<2)
#define P0_17_MISO0         (2<<2)
#define P0_17_MISO          (3<<2)

#define P0_18_DCD1          (1<<4)
#define P0_18_MOSI0         (2<<4)
#define P0_18_MOSI          (3<<4)

#define P0_19_DSR1          (1<<6)
#define P0_19_MCICLK        (2<<6)
#define P0_19_SDA1          (3<<6)

#define P0_20_DTR1          (1<<8)
#define P0_20_MCICMD        (2<<8)
#define P0_20_SCL1          (3<<8)

#define P0_21_RI1           (1<<10)
#define P0_21_MCIPWR        (2<<10)
#define P0_21_RD1           (3<<10)

#define P0_22_RTS1          (1<<12)
#define P0_22_MCIDAT0       (2<<12)
#define P0_22_TD1           (3<<12)

#define P0_23_AD0_0         (1<<14)
#define P0_23_I2SRX_CLK     (2<<14)
#define P0_23_CAP3_0        (3<<14)

#define P0_24_AD0_1         (1<<16)
#define P0_24_I2SRX_WS      (2<<16)
#define P0_24_CAP3_1        (3<<16)

#define P0_25_AD0_2         (1<<18)
#define P0_25_I2SRX_SDA     (2<<18)
#define P0_25_TXD3          (3<<18)

#define P0_26_AD0_3         (1<<20)
#define P0_26_AOUT          (2<<20)
#define P0_26_RXD3          (3<<20)

#define P0_27_SDA0          (1<<22)
//#define P0_27_        //reserved
//#define P0_27_        //reserved

#define P0_28_SCL0          (1<<24)
//#define P0_28_        //reserved
//#define P0_28_        //reserved

#define P0_29_USB_DP1       (1<<26)
//#define P0_29_
//#define P0_29_

#define P0_30_USB_DM1       (1<<28)
//#define P0_30_
//#define P0_30_

#define P0_31_USB_DP2       (1<<30)
//#define P0_31_
//#define P0_31_


//*******************************************************
//PINSEL2
#define P1_0_ENET_TXD0      (1<<0)
#define P1_0_
#define P1_0_

#define P1_1_ENET_TXD1      (1<<2)
//#define P1_1_
//#define P1_1_

/* reserved
#define P1_2_
#define P1_2_
#define P1_2_

#define P1_3_
#define P1_3_
#define P1_3_
*/

#define P1_4_ENET_TX_EN     (1<<8)
//#define P1_4_
//#define P1_4_

/* reserved
#define P1_5_
#define P1_5_
#define P1_5_

#define P1_6_
#define P1_6_
#define P1_6_

#define P1_7_
#define P1_7_
#define P1_7_
*/
#define P1_8_ENET_CRS       (1<<16)
//#define P1_8_
//#define P1_8_

#define P1_9_ENET_RXD0      (1<<18)
//#define P1_9_
//#define P1_9_

#define P1_10_ENET_RXD1     (1<<20)
#define P1_10_
#define P1_10_

/*reserved
#define P1_11_
#define P1_11_
#define P1_11_

#define P1_12_
#define P1_12_
#define P1_12_

#define P1_13_
#define P1_13_
#define P1_13_
*/

#define P1_14_ENET_RX_ER        (1<<28)
//#define P1_14_
//#define P1_14_

#define P1_15_ENET_REF_CLK      (1<<30)
//#define P1_15_
//#define P1_15_

//*******************************************************
// PINSEL3
#define P1_16_ENET_MDC          (1<<0)
//#define P1_16_
//#define P1_16_

#define P1_17_ENET_MDIO         (1<<2)
//#define P1_17_
//#define P1_17_

#define P1_18_USB_UP_LED1       (1<<4)
#define P1_18_PWM1_1            (2<<4)
#define P1_18_CAP1_0            (3<<4)

#define P1_19_USB_TX_E1         (1<<6)
#define P1_19_USB_PPWR1         (2<<6)
#define P1_19_CAP1_1            (3<<6)

#define P1_20_USB_TX_DP1        (1<<8)
#define P1_20_PWM1_2            (2<<8)
#define P1_20_SCK0              (3<<8)

#define P1_21_USB_TX_DM1        (1<<10)
#define P1_21_PWM1_3            (2<<10)
#define P1_21_SSEL0             (3<<10)

#define P1_22_USB_RCV1          (1<<12)
#define P1_22_USB_PWRD1         (2<<12)
#define P1_22_MAT1_0            (3<<12)

#define P1_23_USB_RX_DP1        (1<<14)
#define P1_23_PWM1_4            (2<<14)
#define P1_23_MISO0             (3<<14)

#define P1_24_USB_RX_DM1        (1<<16)
#define P1_24_PWM1_5            (2<<16)
#define P1_24_MOSI0             (3<<16)

#define P1_25_USB_LS1           (1<<18)
#define P1_25_USB_HSTEN1        (2<<18)
#define P1_25_MAT1_1            (3<<18)

#define P1_26_USB_SSPND1        (1<<20)
#define P1_26_PWM1_6            (2<<20)
#define P1_26_USB_CAP0_0        (3<<20)

#define P1_27_USB_INT1          (1<<22)
#define P1_27_USB_OVRCR1        (2<<22)
#define P1_27_CAP0_1            (3<<22)

#define P1_28_USB_SCL1          (1<<24)
#define P1_28_PCAP1_0           (2<<24)
#define P1_28_MAT0_0            (3<<24)

#define P1_29_USB_SDA1          (1<<26)
#define P1_29_PCAP1_1           (2<<26)
#define P1_29_MAT0_1            (3<<26)

#define P1_30_USB_PWRD2         (1<<28)
#define P1_30_VBUS              (1<<28)
#define P1_30_AD0_4             (1<<28)

#define P1_31_USB_OVRCR2        (1<<30)
#define P1_31_SCK1              (2<<20)
#define P1_31_AD0_5             (3<<30)

//*******************************************************
// PINSEL4
#define P2_0_PWM1_1             (1<<0)
#define P2_0_TXD1               (2<<0)
#define P2_0_TRACECLK           (3<<0)

#define P2_1_PWM1_2             (1<<2)
#define P2_1_RXD1               (2<<2)
#define P2_1_PIPESTAT0          (3<<2)

#define P2_2_PWM1_3             (1<<4)
#define P2_2_CTS1               (2<<4)
#define P2_2_PIPESTAT1          (3<<4)

#define P2_3_PWM1_4             (1<<6)
#define P2_3_DCD1               (2<<6)
#define P2_3_PIPESTAT2          (3<<6)

#define P2_4_PWM1_5             (1<<8)
#define P2_4_DSR1               (2<<8)
#define P2_4_TRACESYNC          (3<<8)

#define P2_5_PWM1_6             (1<<10)
#define P2_5_DTR1               (2<<10)
#define P2_5_TRACEPKT0          (3<<10)

#define P2_6_PCAP1_0            (1<<12)
#define P2_6_RI1                (2<<12)
#define P2_6_TRAVEPKT1          (3<<12)

#define P2_7_RD2                (1<<14)
#define P2_7_RTS1               (2<<14)
#define P2_7_TRACEPKT2          (3<<14)

#define P2_8_TD2                (1<<16)
#define P2_8_TXD2               (2<<16)
#define P2_8_TRACEPKT3          (3<<16)

#define P2_9_USB_CONNECT1       (1<<18)
#define P2_9_RXD2               (2<<18)
#define P2_9_EXTIN0             (3<<18)

#define P2_10_EINT0             (1<<20)
//#define P2_10_
//#define P2_10_

#define P2_11_EINT1             (1<<22)
#define P2_11_MCIDAT1           (2<<22)
#define P2_11_I2STX_CLK         (3<<22)

#define P2_12_EINT2             (1<<24)
#define P2_12_MCIDAT2           (2<<24)
#define P2_12_I2STX_WS          (3<<24)

#define P2_13_EINT3             (1<<26)
#define P2_13_MCIDAT3           (2<<26)
#define P2_13_I2STX_SDA         (3<<26)
/*
#define P2_14_
#define P2_14_
#define P2_14_

#define P2_15_
#define P2_15_
#define P2_15_
*/


//*******************************************************
// PINSEL5 - not used

//*******************************************************
// PINSEL6
#define P3_0_D0         (1<<0)
#define P3_1_D1         (1<<2)
#define P3_2_D2         (1<<4)
#define P3_3_D3         (1<<6)
#define P3_4_D4         (1<<8)
#define P3_5_D5         (1<<10)
#define P3_6_D6         (1<<12)
#define P3_7_D7         (1<<14)


//*******************************************************
// PINSEL7

#define P3_23_CAP0_0        (2<<14)
#define P3_23_PCAP1_0       (3<<14)

#define P3_24_CAP0_1        (2<<16)
#define P3_24_PWM1_1        (3<<16)

#define P3_25_MAT0_0        (2<<18)
#define P3_25_PWM1_2        (3<<18)

#define P3_26_MAT0_1        (2<<20)
#define P3_26_PWM1_3        (3<<20)


//*******************************************************
// PINSEL8
#define P4_0_A0             (1<<0)
#define P4_1_A1             (1<<2)
#define P4_2_A2             (1<<4)
#define P4_3_A3             (1<<6)
#define P4_4_A4             (1<<8)
#define P4_5_A5             (1<<10)
#define P4_6_A6             (1<<12)
#define P4_7_A7             (1<<14)
#define P4_8_A8             (1<<16)
#define P4_9_A9             (1<<18)
#define P4_10_A10           (1<<20)
#define P4_11_A11           (1<<22)
#define P4_12_A12           (1<<24)
#define P4_13_A13           (1<<26)
#define P4_14_A14           (1<<28)
#define P4_15_A15           (1<<30)

//*******************************************************
// PINSEL9

#define P4_24_OE            (1<<16)
#define P4_25_BLS0          (2<<18)

#define P4_28_MAT2_0        (2<<24)
#define P4_28_TXD3          (3<<24)

#define P4_29_MAT2_1        (2<<26)
#define P4_29_RXD3          (3<<26)

#define P4_30_CS0           (1<<28)

#define P4_31_CS1           (1<<30)

//*******************************************************
// PINSEL10




#define PIN0_NO_PUD         (2<<0)
#define PIN0_PULL_DOWN      (3<<0)
#define PIN1_NO_PUD         (2<<2)
#define PIN1_PULL_DOWN      (3<<2)
#define PIN2_NO_PUD         (2<<4)
#define PIN2_PULL_DOWN      (3<<4)
#define PIN3_NO_PUD         (2<<6)
#define PIN3_PULL_DOWN      (3<<6)
#define PIN4_NO_PUD         (2<<8)
#define PIN4_PULL_DOWN      (3<<8)
#define PIN5_NO_PUD         (2<<10)
#define PIN5_PULL_DOWN      (3<<10)
#define PIN6_NO_PUD         (2<<12)
#define PIN6_PULL_DOWN      (3<<12)
#define PIN7_NO_PUD         (2<<14)
#define PIN7_PULL_DOWN      (3<<14)
#define PIN8_NO_PUD         (2<<16)
#define PIN8_PULL_DOWN      (3<<16)
#define PIN9_NO_PUD         (2<<18)
#define PIN9_PULL_DOWN      (3<<18)
#define PIN10_NO_PUD        (2<<20)
#define PIN10_PULL_DOWN     (3<<20)
#define PIN11_NO_PUD        (2<<22)
#define PIN11_PULL_DOWN     (3<<22)
#define PIN12_NO_PUD        (2<<24)
#define PIN12_PULL_DOWN     (3<<24)
#define PIN13_NO_PUD        (2<<26)
#define PIN13_PULL_DOWN     (3<<26)
#define PIN14_NO_PUD        (2<<28)
#define PIN14_PULL_DOWN     (3<<28)
#define PIN15_NO_PUD        (2<<30)
#define PIN15_PULL_DOWN     (3<<30)

#define PIN16_NO_PUD         (2<<0)
#define PIN16_PULL_DOWN      (3<<0)
#define PIN17_NO_PUD         (2<<2)
#define PIN17_PULL_DOWN      (3<<2)
#define PIN18_NO_PUD         (2<<4)
#define PIN18_PULL_DOWN      (3<<4)
#define PIN19_NO_PUD         (2<<6)
#define PIN19_PULL_DOWN      (3<<6)
#define PIN20_NO_PUD         (2<<8)
#define PIN20_PULL_DOWN      (3<<8)
#define PIN21_NO_PUD         (2<<10)
#define PIN21_PULL_DOWN      (3<<10)
#define PIN22_NO_PUD         (2<<12)
#define PIN22_PULL_DOWN      (3<<12)
#define PIN23_NO_PUD         (2<<14)
#define PIN23_PULL_DOWN      (3<<14)
#define PIN24_NO_PUD         (2<<16)
#define PIN24_PULL_DOWN      (3<<16)
#define PIN25_NO_PUD         (2<<18)
#define PIN25_PULL_DOWN      (3<<18)
#define PIN26_NO_PUD        (2<<20)
#define PIN26_PULL_DOWN     (3<<20)
#define PIN27_NO_PUD        (2<<22)
#define PIN27_PULL_DOWN     (3<<22)
#define PIN28_NO_PUD        (2<<24)
#define PIN28_PULL_DOWN     (3<<24)
#define PIN29_NO_PUD        (2<<26)
#define PIN29_PULL_DOWN     (3<<26)
#define PIN30_NO_PUD        (2<<28)
#define PIN30_PULL_DOWN     (3<<28)
#define PIN31_NO_PUD        (2<<30)
#define PIN31_PULL_DOWN     (3<<30)



#define PCON_NORMAL         0x00
#define PCON_IDLE           0x01
#define PCON_SLEEP          0x81
#define PCON_PWRD           0x02
#define PCON_DEEP           0x82

#define PCON_BODPDM         (1<<2)
#define PCON_BOGD           (1<<3)
#define PCON_BORD           (1<<4)

#endif